//
//  GuideView.swift
//  WYYao
//
//  Created by wangcl on 2024/9/11.
//

import SwiftUI
//imageModels.indices等同于0..imageModels.count
struct GuidePageView: View {
    @EnvironmentObject var viewModel: ViewModel
    
    let images = ["guide_1","guide_2","guide_3"]
    let texts = ["请您过来","欢迎光临","有事找我"]
    var body: some View {
        TabView {
            ForEach(images.indices,id: \.self) { index in
                VStack(spacing:20,content: {
                    Image(images[index]).resizable().scaledToFit()
                    Text(texts[index]).font(.title).bold()
                    if images[index] == images.last {
                        Button(action: {
                            viewModel.firstLaunch = false
                        }, label: {
                            Text("立即体验")
                                .font(.system(size: 17))
                                .frame(maxWidth: 120)
                                .padding()
                                .foregroundColor(.white)
                                .background(Color.green)
                                .cornerRadius(9)
                        })
                    }else{
                        Image(systemName: "arrow.forward.circle").font(.largeTitle)
                    }
                    
                })
            }
        }.tabViewStyle(PageTabViewStyle())
        .edgesIgnoringSafeArea(.all)
        
        
    }
}

#Preview {
    GuidePageView()
}
